//
//  MainViewController.m
//  NewsHots
//
//  Created by rimi on 2016/12/1.
//  Copyright © 2016年 zhongshuilian. All rights reserved.
//

#import "MainViewController.h"

#pragma mark -  *** 根视图S
#import "ORMyViewController.h"
#import "ORPageViewController.h"
#import "ORHomeViewController.h"


@interface MainViewController ()

@property(nonatomic, strong) NSMutableArray<UIViewController *> *childVCs;

@end

@implementation MainViewController


- (instancetype)init{
    
    self=[super init];
    if (self) {
        self.childVCs=[NSMutableArray array];
        [self initalizeDataSource];
        
    }
    return self;
}



- (void)viewDidLoad {
    [super viewDidLoad];
   
}


#pragma mark - *** 标签栏视图S ***
- (void)initalizeDataSource{
    
    //有几个标签 就调用几次方法；
    
    [self addChildVcWithTitle:@"首页" withClassName:@"ORHomeViewController" withNorImageName:@"首页.jpg" withSeletedImgName:@"首页.jpg"];
    [self addChildVcWithTitle:@"分类" withClassName:@"ORPageViewController" withNorImageName:@"分类.jpg" withSeletedImgName:@"分类.jpg"];
    [self addChildVcWithTitle:@"我的" withClassName:@"ORMyViewController" withNorImageName:@"我的.jpg" withSeletedImgName:@"我的.jpg"];
    
}


- (void)addChildVcWithTitle:(NSString *)title withClassName:(NSString *)className withNorImageName:(NSString *)norImageName withSeletedImgName:(NSString *)seletedImgName{
    
    //视图的标题 默认图片 选中图片
    UIViewController *vc=[[NSClassFromString(className) alloc]init];
    vc.tabBarItem=[[UITabBarItem alloc]initWithTitle:title image:[UIImage imageNamed:norImageName] selectedImage:[UIImage imageNamed:seletedImgName]];
    
//    //导航栏
    UINavigationController *navc=[[UINavigationController alloc]initWithRootViewController:vc];
    navc.navigationBar.titleTextAttributes = @{NSFontAttributeName: [UIFont systemFontOfSize:20],NSForegroundColorAttributeName:[UIColor whiteColor]};
    //导航栏颜色
    navc.navigationBar.barTintColor= MainColor;
    navc.navigationBar.translucent = NO;
    
    [self.childVCs addObject:navc];
    self.viewControllers=self.childVCs;
    self.tabBar.tintColor=[UIColor whiteColor];
    //
    self.tabBar.translucent = NO;
    self.tabBar.barTintColor = MainColor;
    self.tabBarController.tabBar.tintColor = [UIColor yellowColor];
}


@end
